Option Strict Off
Option Explicit On
Friend Class SMSCollection
	
	Public ID As String
	Public Name As String
	Public ParentID As String
	Public OwnedByThisSite As Boolean
	
	Public Function Create(ByRef SMSProviderConnection As WbemScripting.SWbemServices) As Boolean
		
		If Len(Name) = 0 Or Len(ParentID) <> 8 Then
			Create = False
			Exit Function
		End If
		
		Dim objCollection As WbemScripting.SWbemObject 'Instance of SMS_Collection
		Dim objCollectionPath As WbemScripting.SWbemObjectPath 'Path to the created collection
		Dim objCollToSubColl As WbemScripting.SWbemObject 'Instance of SMS_CollectToSubCollect_a
		
		On Error GoTo CreateErr
		
		'Create the collection.
		objCollection = SMSProviderConnection.Get("SMS_Collection").SpawnInstance_
		'UPGRADE_WARNING: Couldn't resolve default property of object objCollection.comment. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		objCollection.comment = ""
		'UPGRADE_WARNING: Couldn't resolve default property of object objCollection.Name. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		objCollection.Name = Name
		'UPGRADE_WARNING: Couldn't resolve default property of object objCollection.OwnedByThisSite. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		objCollection.OwnedByThisSite = True
		objCollectionPath = objCollection.Put_ 'Save the collection path for later
		
		'You must define to what collection the new collection is subordinate.
		'If you do not specify the relationship, the collection will not be visible
		'in the console. Also, populating SMS_CollectToSubCollect_a populates
		'SMS_CollectToSubCollect. Which one you populate is arbitrary.
		objCollToSubColl = SMSProviderConnection.Get("SMS_CollectToSubCollect").SpawnInstance_
		'UPGRADE_WARNING: Couldn't resolve default property of object objCollToSubColl.parentCollectionID. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		objCollToSubColl.parentCollectionID = ParentID
		'UPGRADE_WARNING: Couldn't resolve default property of object objCollToSubColl.subCollectionID. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		objCollToSubColl.subCollectionID = CStr(objCollectionPath.Keys.Item("CollectionID").Value)
		objCollToSubColl.Put_()
		
		'UPGRADE_NOTE: Object objCollToSubColl may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		objCollToSubColl = Nothing
		'UPGRADE_NOTE: Object objCollection may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		objCollection = Nothing
		
		Create = True
		Exit Function
CreateErr: 
		
		Create = False
		
	End Function
	
	'UPGRADE_NOTE: Class_Initialize was upgraded to Class_Initialize_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
	Private Sub Class_Initialize_Renamed()
		ID = ""
		Name = ""
		ParentID = ""
		OwnedByThisSite = True
	End Sub
	Public Sub New()
		MyBase.New()
		Class_Initialize_Renamed()
	End Sub
End Class